<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" name="" id="input">
    <script>
        var arr = [
            {"name":"逐梦演艺圈，圈住你","id":1102},
            {"name":"我爱你","id":1103},
            {"name":"hello","id":1104},
            {"name":"world","id":1105},
            {"name":"怪你","id":1106},
            {"name":"绅士","id":1107}
        ];
        var input = document.getElementById("input");

        input.onkeydown= function(event){
            if (event.keyCode == 13 && this.value!=""){
                console.log(this.value);
                var value = this.value;
                var res = arr.filter(item => item.name.includes(value));
                var result = res.map( (deal) => {
                    if (deal.name.length>5){
                        deal.name = deal.name.slice(0,5)+"...";
                        // console.log(deal.name);
                        return deal;
                    }
                    return deal;
                    // console.log(deal);
                })
                console.log(res);
            }
            
        }


    </script>
</body>
</html>